clear 
clear global
Tessa1Tobi2=1
 if Tessa1Tobi2==2
        outputpath=sprintf('C:/Users/tbroer/Dropbox/Research/Current_Projects/tessa/JEEA Replication/Programmes/APPROXIMATE_EXACT')
        programpath=sprintf('C:/Users/tbroer/Dropbox/Research/Current_Projects/tessa/JEEA Replication/Programmes/APPROXIMATE_EXACT')
    elseif Tessa1Tobi2==1
        
        outputpath=sprintf('C:/Users/tbold/Dropbox/Tessa and Tobi/JEEA Replication/Programmes/APPROXIMATE_EXACT')
        programpath=sprintf('C:/Users/tbold/Dropbox/Tessa and Tobi/JEEA Replication/Programmes')
    end
for coaldev=0:1
cd(outputpath)
eval(['load ASYMMETRY' int2str(coaldev) '.mat'])
cd ..

for group=1:12
%%%moments for sample when two are constrained
rrdata=find(yy_cond((group-1)*3+3,:)<=0 & yy_cond((group-1)*3+1,:)>0 & yy_cond((group-1)*3+2,:)>0);
rr=rrdata;
YY_cond=cc_cond((group-1)*3+1,rr)';
XX_cond=[ones(length(rr),1) yy_cond((group-1)*3+1,rr)'];
regress(YY_cond,XX_cond);
b(2,group)=ans(2);
YY_cond=cc_cond((group-1)*3+3,rr)';
XX_cond=[ones(length(rr),1) yy_cond((group-1)*3+3,rr)'];
regress(YY_cond,XX_cond);
b(3,group)=ans(2);

%%%%and the average degree of risk-sharing. 
bb=[];
YY_cond=cc_cond(1,rr)';
XX_cond=[ones(length(rr),1) yy_cond(1,rr)'];
regress(YY_cond,XX_cond);
bb=[bb ans(2)];
YY_cond=cc_cond(2,rr)';
XX_cond=[ones(length(rr),1) yy_cond(2,rr)'];
regress(YY_cond,XX_cond);
bb=[bb ans(2)];
YY_cond=cc_cond(3,rr)';
XX_cond=[ones(length(rr),1) yy_cond(3,rr)'];
regress(YY_cond,XX_cond);
bb=[bb ans(2)];
b(1,group)=mean(bb);
end
%%%entries in the table%%%
TABLEENTRIES(:,:,coaldev+1)=[ Momentsest1(15,1)  mean(b(1,:)) ; ...
Momentsest1(16,1)-Momentsest1(17,1)  mean(b(2,:)-b(3,:))];
end
%ID model, full sample, restricted sample
TABLEENTRIES(:,:,1)
%CD model, full sample, restricted sample
TABLEENTRIES(:,:,2)

